package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.PressureSensor;
import com.ruoyi.system.service.IPressureSensorService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 压力传感器数据Controller
 * 
 * @author ruoyi
 * @date 2025-10-28
 */
@RestController
@RequestMapping("/system/pressureSensor")
public class PressureSensorController extends BaseController
{
    @Autowired
    private IPressureSensorService pressureSensorService;

    /**
     * 查询压力传感器数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:pressureSensor:list')")
    @GetMapping("/list")
    public TableDataInfo list(PressureSensor pressureSensor)
    {
        startPage();
        List<PressureSensor> list = pressureSensorService.selectPressureSensorList(pressureSensor);
        return getDataTable(list);
    }

    /**
     * 导出压力传感器数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:pressureSensor:export')")
    @Log(title = "压力传感器数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PressureSensor pressureSensor)
    {
        List<PressureSensor> list = pressureSensorService.selectPressureSensorList(pressureSensor);
        ExcelUtil<PressureSensor> util = new ExcelUtil<PressureSensor>(PressureSensor.class);
        util.exportExcel(response, list, "压力传感器数据数据");
    }

    /**
     * 获取压力传感器数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:pressureSensor:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(pressureSensorService.selectPressureSensorById(id));
    }

    /**
     * 新增压力传感器数据
     */
    @PreAuthorize("@ss.hasPermi('system:pressureSensor:add')")
    @Log(title = "压力传感器数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PressureSensor pressureSensor)
    {
        return toAjax(pressureSensorService.insertPressureSensor(pressureSensor));
    }

    /**
     * 修改压力传感器数据
     */
    @PreAuthorize("@ss.hasPermi('system:pressureSensor:edit')")
    @Log(title = "压力传感器数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PressureSensor pressureSensor)
    {
        return toAjax(pressureSensorService.updatePressureSensor(pressureSensor));
    }

    /**
     * 删除压力传感器数据
     */
    @PreAuthorize("@ss.hasPermi('system:pressureSensor:remove')")
    @Log(title = "压力传感器数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pressureSensorService.deletePressureSensorByIds(ids));
    }
}
